<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./lib/themes/metro/easyui.css" />
    <link rel="stylesheet" href="./lib/themes/icon.css" />
</head>
<body>
    <div id="app" >
        <div id="menu" data-bind="component:comp"></div> 
        <div data-bind="html:index"></div>
        <button data-bind="click:add">切换</button> 
    </div>
    <script src="./lib/jquery.min.js"></script>
    <script src="./lib/jquery.easyui.min.js"></script>
    <script src="./lib/locale/easyui-lang-zh_CN.js"></script>
    <script src="./lib/knockout-3.5.0.js" ></script>
    <script src="/koeasyui.js"></script>
    <script>
        koeasyui.use(window.ko); 
        var i = 0;
        var ar = ['ko-datagrid', 'ko-layout', 'ko-menu', 'ko-combobox', 'ko-combogrid', 
        'ko-combotreegrid', 'ko-combo', 'ko-datetimebox', 'ko-datebox', 'ko-searchbox', 'ko-combotree', 'ko-textbox']
        var componentVm={
            name: ko.observable('ko-datagrid'),
            params: {
               options:{}
            }
        }
        var rootVm={
            comp:ko.observable(componentVm),
            index: ko.observable('0 ko-datagrid'),
            add:function(){ 
                componentVm.name(ar[++i]);
                this.index(i + ' ' + ar[i]);
                if(i >= ar.length - 1){
                    i = -1;
                }
            }
        };
        ko.applyBindings(rootVm, document.getElementById('app'));
    </script>
</body>
</html>